package com.dididoctor.doctor.Bean;

import android.content.Context;

import com.dididoctor.doctor.Activity.GlobalParams;
import com.dididoctor.doctor.Utils.SharedPreferencesUtils;


/**
 * @version 2.0
 * @类描述： Token
 * @项目名称：ddgh
 * @类名称： Token
 * @包名称： com.doudoukeji.service.Bean
 * @创建人：张强 boy
 * @创建时间：2016/3/14 15:54
 * @修改人：
 * @修改时间：2016/3/14 15:54
 * @修改备注： new parent class(用一句话描述修改了什么)
 */

public class Token {
    //    "userId": "5",//用户
    //                "online":"1",//是否在线
//                "isSign”:””//家庭医生
//        "callSwitch":"1",//是否有电话
//                "phone": "13963941179",//用户手机号
//                "name": "139****1179",//用户名称没有用户名的情况下，用户名为手机号前三位＋＊＊＊＊＋后四位
//                "headPic":"头像"
//        "sex":"性别"
//        "qrcode”:”二维码”
//        "birth":"出生日期"
//        "idNo":"身份证号"
//        "city":"城市"
//        "wtId":"职称"
//        "isPass”:”是否认证”
//        "accId":"云信ID"
//        "accPwd":"登录token值"
//        "token": "afdsgjfkljgljeoirewl;gfdkasjkfj",//唯一识别码
    private static String userId;//用户
    private static String phone;//手机号
    private static String name;//用户名
    private static String headPic;//头像
    private static String sex;//性别
    private static String birth;//出生日期
    private static String idNo;//身份证号
    private static String city;//城市
    private static String address;//详细信息
    private static String token;//唯一识别码
    private static String disVersion;//24中小病版本号
    private static String accId;//网易登陆用户名
    private static String accPwd;//网易登陆密码
    private static String online;//是否在线
    private static String isSign;//家庭医生
    private static String callSwitch;//是否有电话
    private static String qrcode;//二维码”
    private static String wtId;//"职称"
    private static String isPass;//是否认证”
    private static String certificateID;//资格认证id
    private static String certificateUrl;//资格认证url


    private static String USERID = "userId";//用户
    private static String PHONE = "phone";//手机号
    private static String NAME = "name";//用户名
    private static String HEADPIC = "headPic";//头像
    private static String SEX = "sex";//性别
    private static String BIRTH = "birth";//出生日期
    private static String IDNO = "idNo";//身份证号
    private static String CITY = "city";//城市
    private static String ADDRESS = "address";//详细信息
    private static String TOKEN = "token";//唯一识别码
    private static String DISVERSION = "disVersion";//24中小病版本号
    private static String ACCID = "accId";//网易登陆用户名
    private static String ACCPWD = "accPwd";//网易登陆密码
    private static String ONLINE = "online";//是否在线
    private static String ISSIGN = "isSign";//家庭医生
    private static String CALLSWITCH = "callSwitch";//是否有电话
    private static String QRCODE = "qrcode";//二维码”
    private static String WTID = "wtId";//"职称"
    private static String ISPASS = "isPass";//是否认证”
    private static String CERTIFICATEID = "certificateID";//是否认证”
    private static String CERTIFICATEURL = "certificateUrl";//certificateUrl”

    public static Context mcontext;

    public static String getAccId() {
        if (!"".equals(accId) && accId != null) {
            return accId;
        } else {
            accId = SharedPreferencesUtils.getParam(mcontext, Token.ACCID, "");
            return accId;
        }
    }

    public static void setAccId(String accId) {
        Token.accId = accId;
        SharedPreferencesUtils.setParam(mcontext, Token.ACCID, accId);
    }

    public static String getAccPwd() {
        return accPwd;
    }

    public static void setAccPwd(String accPwd) {
        Token.accPwd = accPwd;
    }


    public static String getDisVersion() {
        if (!"".equals(disVersion) && disVersion != null) {
            return disVersion;
        } else {
            disVersion = SharedPreferencesUtils.getParam(mcontext, Token.DISVERSION, "");
            return disVersion;
        }
    }

    public static void setDisVersion(String disVersion) {
        Token.disVersion = disVersion;
        SharedPreferencesUtils.setParam(mcontext, Token.DISVERSION, disVersion);
    }

    public static String getIsPass() {
        if (!"".equals(isPass) && isPass != null) {
            return isPass;
        } else {
            isPass = SharedPreferencesUtils.getParam(mcontext, Token.ISPASS, "");
            return isPass;
        }
    }

    public static void setIsPass(String isPass) {
        Token.isPass = isPass;
        SharedPreferencesUtils.setParam(mcontext, Token.ISPASS, isPass);
    }

    public static String getCertificateID() {
        if (!"".equals(certificateID) && certificateID != null) {
            return certificateID;
        } else {
            certificateID = SharedPreferencesUtils.getParam(mcontext, Token.CERTIFICATEID, "");
            return certificateID;
        }
    }

    public static void setCertificateID(String certificateID) {
        Token.certificateID = certificateID;
        SharedPreferencesUtils.setParam(mcontext, Token.CERTIFICATEID, certificateID);
    }

    public static String getCertificateUrl() {
        if (!"".equals(certificateUrl) && certificateUrl != null) {
            return certificateUrl;
        } else {
            certificateUrl = SharedPreferencesUtils.getParam(mcontext, Token.CERTIFICATEURL, "");
            return certificateUrl;
        }
    }

    public static void setCertificateUrl(String certificateUrl) {
        Token.certificateUrl = certificateUrl;
        SharedPreferencesUtils.setParam(mcontext, Token.CERTIFICATEURL, certificateUrl);
    }

    public static String getPhone() {
        if (!"".equals(phone) && phone != null) {
            return phone;
        } else {
            phone = SharedPreferencesUtils.getParam(mcontext, Token.PHONE, "");
            return phone;
        }
    }

    public static void setPhone(String phone) {
        Token.phone = phone;
        SharedPreferencesUtils.setParam(mcontext, Token.PHONE, phone);
    }

    public static String getUserId() {
        if (!"".equals(userId) && userId != null) {
            return userId;
        } else {
            userId = SharedPreferencesUtils.getParam(mcontext, Token.USERID, "");
            return userId;
        }
    }

    public static void setUserId(String userId) {
        Token.userId = userId;
        SharedPreferencesUtils.setParam(mcontext, Token.USERID, userId);
    }

    public static String getOnline() {
        if (!"".equals(online) && online != null) {
            return online;
        } else {
            online = SharedPreferencesUtils.getParam(mcontext, Token.ONLINE, "");
            return online;
        }
    }

    public static void setOnline(String online) {
        Token.online = online;
        SharedPreferencesUtils.setParam(mcontext, Token.ONLINE, online);
    }

    public static String getIsSign() {
        if (!"".equals(isSign) && isSign != null) {
            return isSign;
        } else {
            isSign = SharedPreferencesUtils.getParam(mcontext, Token.ISSIGN, "");
            return isSign;
        }
    }

    public static void setIsSign(String isSign) {
        Token.isSign = isSign;
        SharedPreferencesUtils.setParam(mcontext, Token.ISSIGN, isSign);
    }

    public static String getCallSwitch() {
        if (!"".equals(callSwitch) && callSwitch != null) {
            return callSwitch;
        } else {
            callSwitch = SharedPreferencesUtils.getParam(mcontext, Token.CALLSWITCH, "");
            return callSwitch;
        }
    }

    public static void setCallSwitch(String callSwitch) {
        Token.callSwitch = callSwitch;
        SharedPreferencesUtils.setParam(mcontext, Token.CALLSWITCH, callSwitch);
    }

    public static String getQrcode() {
        if (!"".equals(qrcode) && qrcode != null) {
            return qrcode;
        } else {
            qrcode = SharedPreferencesUtils.getParam(mcontext, Token.QRCODE, "");
            return qrcode;
        }
    }

    public static void setQrcode(String qrcode) {
        Token.qrcode = qrcode;
        SharedPreferencesUtils.setParam(mcontext, Token.QRCODE, qrcode);
    }

    public static String getWtId() {
        if (!"".equals(wtId) && wtId != null) {
            return wtId;
        } else {
            wtId = SharedPreferencesUtils.getParam(mcontext, Token.WTID, "");
            return wtId;
        }
    }

    public static void setWtId(String wtId) {
        Token.wtId = wtId;
        SharedPreferencesUtils.setParam(mcontext, Token.WTID, wtId);
    }

    public static String getName() {
        if (!"".equals(name) && name != null) {
            return name;
        } else {
            name = SharedPreferencesUtils.getParam(mcontext, Token.NAME, "");
            return name;
        }
    }

    public static void setName(String name) {
        Token.name = name;
        SharedPreferencesUtils.setParam(mcontext, Token.NAME, name);
    }

    public static String getHeadPic() {
        if (!"".equals(headPic) && headPic != null) {
            return headPic;
        } else {
            headPic = SharedPreferencesUtils.getParam(mcontext, Token.HEADPIC, "");
            return headPic;
        }
    }

    public static void setHeadPic(String headPic) {
        Token.headPic = headPic;
        SharedPreferencesUtils.setParam(mcontext, Token.HEADPIC, headPic);
    }

    public static String getSex() {
        if (!"".equals(sex) && sex != null) {
            return sex;
        } else {
            sex = SharedPreferencesUtils.getParam(mcontext, Token.SEX, "");
            return sex;
        }
    }

    public static void setSex(String sex) {
        Token.sex = sex;
        SharedPreferencesUtils.setParam(mcontext, Token.SEX, sex);
    }

    public static String getBirth() {
        if (!"".equals(birth) && birth != null) {
            return birth;
        } else {
            birth = SharedPreferencesUtils.getParam(mcontext, Token.BIRTH, "");
            return birth;
        }
    }

    public static void setBirth(String birth) {
        Token.birth = birth;
        SharedPreferencesUtils.setParam(mcontext, Token.BIRTH, birth);
    }

    public static String getIdNo() {
        if (!"".equals(idNo) && idNo != null) {
            return idNo;
        } else {
            idNo = SharedPreferencesUtils.getParam(mcontext, Token.IDNO, "");
            return idNo;
        }
    }

    public static void setIdNo(String idNo) {
        Token.idNo = idNo;
        SharedPreferencesUtils.setParam(mcontext, Token.IDNO, idNo);
    }

    public static String getCity() {
        if (!"".equals(city) && city != null) {
            return city;
        } else {
            city = SharedPreferencesUtils.getParam(mcontext, Token.CITY, "");
            return city;
        }
    }

    public static void setCity(String city) {
        Token.city = city;
        SharedPreferencesUtils.setParam(mcontext, Token.CITY, city);
    }

    public static String getAddress() {
        if (!"".equals(address) && address != null) {
            return address;
        } else {
            address = SharedPreferencesUtils.getParam(mcontext, Token.ADDRESS, "");
            return address;
        }
    }

    public static void setAddress(String address) {
        Token.address = address;
        SharedPreferencesUtils.setParam(mcontext, Token.ADDRESS, address);
    }

    public static String getToken() {
        if (!"".equals(token) && token != null) {
            return token;
        } else {
            token = SharedPreferencesUtils.getParam(mcontext, Token.TOKEN, "");
            return token;
        }
    }

    public static void setToken(String token) {
        Token.token = token;
        SharedPreferencesUtils.setParam(mcontext, Token.TOKEN, token);
    }


    public static Context getMcontext() {
        if (Token.mcontext != null) {
            return Token.mcontext;
        }
        return GlobalParams.getContext();
    }

    public static void setMcontext(Context mcontext) {
        if (Token.getMcontext() == null && mcontext != null) {
            Token.mcontext = mcontext;
        }
    }


    /**
     * 注销Token
     */
    public static void logout() {
        Token.userId = "";
        Token.setUserId("");
        Token.phone = "";
        Token.setPhone("");
        Token.name = "";
        Token.setName("");
        Token.headPic = "";
        Token.setHeadPic("");
        Token.sex = "";
        Token.setSex("");
        Token.birth = "";
        Token.setBirth("");
        Token.idNo = "";
        Token.setIdNo("");
        Token.city = "";
        Token.setCity("");
        Token.address = "";
        Token.setAddress("");
        Token.token = "";
        Token.setToken("");
        Token.isPass = "";
        Token.setIsPass("");
        Token.certificateID = "";
        Token.setCertificateID("");
        Token.certificateUrl = "";
        Token.setCertificateUrl("");
    }


}
